package com.pwt.controller.crustallus;

import com.pwt.common.CustomException;
import com.pwt.model.CrustalLusModel;
import com.pwt.model.crustallus.FanDiagramModel;
import com.pwt.model.crustallus.GroupModel;
import com.pwt.service.AnalyseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author dw
 * @version 1.0.0
 * @date 2021/10/13
 */
@RestController
@RequestMapping("/analyse")
@Tag(name = "分析页面")
public class AnalyseController {

    private AnalyseService analyseService;

    public AnalyseController(AnalyseService analyseService) {
        this.analyseService = analyseService;
    }


    @GetMapping("/fan-diagrams")
    @Operation(description = "用户所有数据扇形图",summary = "用户所有数据扇形图")
    @Parameters({
            @Parameter(name = "filterId",description = "过滤器id",required = false),
            @Parameter(name = "startTime",description = "开始时间 yyyy-MM-dd HH:mm:ss",required = true),
            @Parameter(name = "endTime",description = "结束时间 yyyy-MM-dd HH:mm:ss",required = true)
    })
    public List<FanDiagramModel> getAnalyseFanDiagramModel(@RequestParam(required = false) String filterId, String startTime, String endTime) {
        return this.analyseService.getAnalyseFanDiagramModel( filterId, startTime,  endTime);
    }


    @GetMapping("/process-diagram")
    @Operation(description = "工位扇形图  根据",summary = "工位扇形图")
    @Parameters({
            @Parameter(name = "filterId",description = "过滤器id",required = false),
            @Parameter(name = "startTime",description = "开始时间 yyyy-MM-dd HH:mm:ss",required = true),
            @Parameter(name = "endTime",description = "结束时间 yyyy-MM-dd HH:mm:ss",required = true)
    })
    public List<FanDiagramModel> getAnalyseProcessDiagramList(@RequestParam(required = false) String filterId, String startTime, String endTime) {
        return this.analyseService.getAnalyseProcessDiagramList( filterId,  startTime,  endTime);
    }

    @GetMapping("/machine-flow")
    @Operation(description = "机床矩形图",summary = "机床矩形图")
    @Parameters({
            @Parameter(name = "filterId",description = "过滤器id",required = false),
            @Parameter(name = "processIds",description = "工序ids 例：1,2,3",required = false),
            @Parameter(name = "partIds",description = "零件id 例：1,2,3",required = false),
            @Parameter(name = "nestIds",description = "巢穴编号 例：1,2,3",required = false),
            @Parameter(name = "startTime",description = "开始时间 yyyy-MM-dd HH:mm:ss",required = true),
            @Parameter(name = "endTime",description = "结束时间 yyyy-MM-dd HH:mm:ss",required = true)

    })
    public List<GroupModel> getAnalyseProcessFlowList(@RequestParam(required = false) String filterId,@RequestParam(required = false) String processIds,
                                              @RequestParam(required = false) String partIds,@RequestParam(required = false) String nestIds,String startTime, String endTime) {
        return this.analyseService.getAnalyseMachineFlowList( filterId, processIds, partIds, nestIds, startTime,  endTime);
    }

    @GetMapping("/part")
    @Operation(description = "零件矩形图",summary = "零件矩形图")
    @Parameters({
            @Parameter(name = "filterId",description = "过滤器id",required = false),
            @Parameter(name = "processIds",description = "工序ids 例：1,2,3",required = false),
            @Parameter(name = "nestIds",description = "巢穴编号 例：1,2,3",required = false),
            @Parameter(name = "startTime",description = "开始时间 yyyy-MM-dd HH:mm:ss",required = true),
            @Parameter(name = "endTime",description = "结束时间 yyyy-MM-dd HH:mm:ss",required = true)
    })
    public List<GroupModel> getAnalysePart(@RequestParam(required = false) String filterId,@RequestParam(required = false) String processIds,
                                              @RequestParam(required = false) String nestIds,String startTime, String endTime) {
        return this.analyseService.getAnalysePart(filterId, processIds, nestIds, startTime,  endTime);
    }


    @GetMapping("/nest")
    @Operation(description = "巢穴矩形图",summary = "巢穴矩形图")
    @Parameters({
            @Parameter(name = "filterId",description = "过滤器id",required = false),
            @Parameter(name = "processIds",description = "工序ids 例：1,2,3",required = false),
            @Parameter(name = "partIds",description = "零件id 例：1,2,3",required = false),
            @Parameter(name = "nestIds",description = "巢穴编号 例：1,2,3",required = false),
            @Parameter(name = "startTime",description = "开始时间 yyyy-MM-dd HH:mm:ss",required = true),
            @Parameter(name = "endTime",description = "结束时间 yyyy-MM-dd HH:mm:ss",required = true)
    })
    public List<GroupModel> getAnalyseNest(@RequestParam(required = false) String filterId,@RequestParam(required = false) String processIds,
                                           @RequestParam(required = false) String partIds,
                                           @RequestParam(required = false) String nestIds,String startTime, String endTime) {
        return this.analyseService.getAnalyseNest(filterId, processIds, partIds,nestIds, startTime,  endTime);
    }

}
